package it.afs.worklog.application.form;

import java.util.List;

import it.afs.worklog.User;

import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;

public class UtenteDropDownChoice extends DropDownChoice<User>
{
	private static final long serialVersionUID = -2453343182670987122L;

	public UtenteDropDownChoice(String id, IModel<? extends List<? extends User>> choices)
	{
		super(id, choices);
	}

	public UtenteDropDownChoice(String id, IModel<User> model, List<? extends User> choices)
	{
		super(id, model, choices);
	}
	
	public UtenteDropDownChoice(String id, IModel<User> model, IModel<? extends List<? extends User>> choices) {
		super(id, model, choices);
	}

	@Override
	protected void onConfigure()
	{
		setChoiceRenderer(new UtenteChoiceRenderer());
		super.onConfigure();
	}

	private class UtenteChoiceRenderer implements IChoiceRenderer<User>
	{
		private static final long serialVersionUID = 8244553088808048061L;

		@Override
		public Object getDisplayValue(User object)
		{
			return object.getNome();
		}

		@Override
		public String getIdValue(User object, int index)
		{
			return String.valueOf(index);
		}
	}
}